package com.example.chandao.common.model;

import cn.hutool.core.collection.CollUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class DictData implements Serializable {

    // 选项实际值
    private String value;

    // 选项显示值
    private String label;

    // 分值
    private Integer score;



    public static Map<String, String> toMap(List<DictData> dictList) {
        if (CollUtil.isEmpty(dictList))
            return Collections.emptyMap();
        return dictList.stream().collect(Collectors.toMap(DictData::getValue, DictData::getLabel));
    }


    public static Map<String, DictData> toObjMap(List<DictData> dictList) {
        if (CollUtil.isEmpty(dictList))
            return Collections.emptyMap();
        return dictList.stream().collect(Collectors.toMap(DictData::getValue, Function.identity()));
    }







}
